﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using IEx.Model.Partials;
using IEx.Utilities;

namespace IEx.ParserBuilder.Clipvn
{
    public class ClipvnParser : IHtmlParser
    {
        public void Parse(SourceItem item, string html, Action<Model.Partials.Announcement> attachResultItem, Action<SourceItem> attachNewItemSource)
        {
            string threadListId = "id=\"main-content\"";
            string navpopupId = "class=\"box box-fb\"";
            string remainHtml = Utility.GetHtmlBody(html, threadListId, navpopupId);
            List<Announcement> detectedAnnouncements = new List<Announcement>();
            Uri newUri = new Uri(item.Url);
            if (!string.IsNullOrEmpty(remainHtml))
            {
                Regex regVlink = new Regex("<a title=\".*?\" class=\"vlink\">.*?</a>");
                MatchCollection mVlink = regVlink.Matches(remainHtml);
                for (int i = 0; i < mVlink.Count; i++)
                {
                    string mVlinkHtml = mVlink[i].Value;
                    string link = RegexUtility.ExtractHyperlink(mVlinkHtml);                    
                    string title = RegexUtility.ExtractTextFromHtmlTag(mVlinkHtml);
                }
            }
        }
    }
}
